<?php
/**
 * User: YL
 * Date: 2019/09/12
 */

namespace restful\traits;

use Illuminate\Support\Collection;

trait TokenController
{
    /**
     * 登录用户信息
     * @var Collection
     */
    protected $info;

    /**
     * 登录用户id
     * @var int
     */
    protected $id = 0;

    /**
     * 初始化操作
     */
    protected function initialize()
    {
        if (! empty($this->request->tokenData)) {
            $this->info = $this->request->tokenData['info'] ?? [];
            $this->id = $this->info['id'] ?? 0;
        }
    }
}
